home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWMemory / Include / FWMemTas.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  2.5 KB  |  90 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWMemTas.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWMEMTAS_H
  13. #define FWMEMTAS_H
  14.  
  15. #ifndef   FWPRITAS_H
  16. #include "FWPriTas.h"
  17. #endif
  18.  
  19. #ifndef FWMEMMGR_H
  20. #include "FWMemMgr.h"
  21. #endif
  22.  
  23. //========================================================================================
  24. // Forward class declarations
  25. //========================================================================================
  26.  
  27. class FW_CMemoryHeap;
  28.  
  29. //========================================================================================
  30. // Struct FW_SPrivMemoryGlobals
  31. //========================================================================================
  32.  
  33. struct FW_SPrivMemoryGlobals
  34. {
  35.     FW_CMemoryHeap* gMemoryHeap;            // The heap
  36.     FW_PFVV gNewHandler;                    // The new handler
  37.     unsigned long gLastRequested;            // The last requested block size
  38. #ifdef FW_qUsePlatformAlloc
  39.     short gInitialized;
  40.         // gInitialized is necessary for this qUsePlatformAlloc case as
  41.         // a replacement for giving gMemoryHeap a nonzero value.
  42. #endif
  43. };
  44.  
  45. //========================================================================================
  46. // CLASS FW_CMemoryTaskGlobals
  47. //========================================================================================
  48.  
  49. class FW_CMemoryTaskGlobals
  50. {
  51. public:
  52.     static FW_SPrivMemoryGlobals& GetMemoryGlobals();
  53.  
  54.     static void SetMemoryHeap(FW_CMemoryHeap* aMemoryHeap);
  55.     
  56.     static void Initialize(FW_SPrivMemoryGlobals& memGlobals);
  57.     static void Terminate();
  58.  
  59.     static void InitializeMemoryHeap(FW_SPrivMemoryGlobals& memGlobals);
  60.     static void TerminateMemoryHeap();
  61.  
  62. private:
  63.  
  64.     enum {kMemoryGlobalsOffset = 126};
  65.     
  66.     FW_CMemoryTaskGlobals();
  67. };
  68.  
  69.  
  70. //----------------------------------------------------------------------------------------
  71. //    FW_CMemoryTaskGlobals::GetMemoryGlobals
  72. //----------------------------------------------------------------------------------------
  73.  
  74. inline FW_SPrivMemoryGlobals& FW_CMemoryTaskGlobals::GetMemoryGlobals()
  75. {
  76.     FW_SPrivMemoryGlobals *globals = (FW_SPrivMemoryGlobals*)
  77.                 FW_CPrivTaskGlobals::GetTaskGlobals(kMemoryGlobalsOffset);
  78.     FW_PRIV_ASSERT(globals != 0);
  79. #ifdef FW_qUsePlatformAlloc
  80.     if (globals->gInitialized == 0)
  81.         Initialize(*globals);
  82. #else
  83.     if (globals->gMemoryHeap == 0)
  84.         Initialize(*globals);
  85. #endif
  86.     return *globals;
  87. }
  88.  
  89. #endif
  90.